package com.tianhui.consignortwofei.mvp.ui.viewHolder.detail;

import android.text.TextUtils;
import android.view.ViewGroup;
import android.widget.TextView;

import com.tianhui.consignortwofei.R;
import com.tianhui.consignortwofei.mvp.model.enty.detailItem.DetailFreightTipInfo;
import com.tianhui.consignortwofei.pattern.freightCalculation.CalculationController;

import org.yczbj.ycrefreshviewlib.holder.BaseViewHolder;

/**
 * @author fgs
 * @date 2020/9/8
 * @description
 **/
public class DetailFreightTipViewHolder extends BaseViewHolder<DetailFreightTipInfo> {
    private TextView deductPriceTextView;
    private TextView insuranceChargeTextView;
    private TextView servicePriceTextView;
    private TextView driverOtherPriceTextView;
    private TextView brokerCommissionTextView;
    private TextView totalPriceTextView;
    private TextView driverPriceTextView;
    private TextView taxTotalPriceTextView;

    public DetailFreightTipViewHolder(ViewGroup parent, int res) {
        super(parent, res);
        deductPriceTextView = getView(R.id.item_detail_freight_tip_deductPriceTextView);
        insuranceChargeTextView = getView(R.id.item_detail_freight_tip_insuranceChargeTextView);
        servicePriceTextView = getView(R.id.item_detail_freight_tip_servicePriceTextView);
        driverOtherPriceTextView = getView(R.id.item_detail_freight_tip_driverOtherPriceTextView);
        brokerCommissionTextView = getView(R.id.item_detail_freight_tip_brokerCommissionTextView);
        driverPriceTextView = getView(R.id.item_detail_freight_tip_driverPriceTextView);
        totalPriceTextView = getView(R.id.item_detail_freight_tip_totalPriceTextView);
        taxTotalPriceTextView = getView(R.id.item_detail_freight_tip_taxTotalPriceTextView);

        addOnClickListener(R.id.item_detail_freight_tip_submitButton);
        addOnClickListener(R.id.item_detail_freight_tip_cancelButton);
    }

    @Override
    public void setData(DetailFreightTipInfo data) {
        super.setData(data);
        deductPriceTextView.setText("亏吨扣除：" + CalculationController.getInstance().getDeductPrice(data.orderInfo));
        if (!TextUtils.isEmpty(data.insurePrice)) {
            insuranceChargeTextView.setText("保险费用：" + data.insurePrice);
        } else {
            insuranceChargeTextView.setText("保险费用：0");
        }

        if (!TextUtils.isEmpty(data.servicePrice)) {
            servicePriceTextView.setText("信息服务费：" + data.servicePrice);
        } else {
            servicePriceTextView.setText("信息服务费：0");
        }
        driverOtherPriceTextView.setText("其他费用：" + data.driverOtherPrice);
        brokerCommissionTextView.setText("经济人金额：" + data.brokercommission);
        driverPriceTextView.setText("司机运费：" + data.driverPrice);
        totalPriceTextView.setText("运费总价格：" + data.totalPrice);
        taxTotalPriceTextView.setText("含税运费总价格：" + data.taxTotalPrice);
    }
}
